package com.dongdongshop.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.dongdongshop.front.pojo.TbContentCategory;
import com.dongdongshop.front.service.ContentCategoryService;
import com.dongdongshop.mapper.TbContentCategoryMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@Service
@Component
public class ContentCategoryServiceImpl implements ContentCategoryService {

    @Autowired
    private TbContentCategoryMapper contentCategoryMapper;

    @Override
    public List<TbContentCategory> getContentCategoryOrName(String name) {
        List<TbContentCategory> contentCategoryList = contentCategoryMapper.getContentCategoryOrName(name);
        return contentCategoryList;
    }

    @Override
    public void addContentCategory(String name) {
        TbContentCategory tb = new TbContentCategory();
        tb.setName(name);
        contentCategoryMapper.insert(tb);
    }

    @Override
    public TbContentCategory getContentCategoryById(Long id) {
        TbContentCategory contentCategory = contentCategoryMapper.selectByPrimaryKey(id);
        return contentCategory;
    }

    @Override
    public void updateContentCategory(TbContentCategory contentCategory) {
        contentCategoryMapper.updateByPrimaryKey(contentCategory);
    }

    @Override
    public void deleteByIds(Long[] ids) {
        contentCategoryMapper.deleteByIds(ids);
    }
}
